//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.dao.wills;

import com.aidong.dao.wills.BaseDao;
import com.aidong.model.wills.PromotionProductReceive;
import com.aidong.model.wills.PssProductCode;
import java.util.Iterator;
import java.util.List;
import org.springframework.stereotype.Repository;

@Repository
public class PromotionProductReceiveDao extends BaseDao<PromotionProductReceive, Integer> {
	public PromotionProductReceiveDao() {
	}

	public List<PssProductCode> getProductByMember(String memberCode) {
		String sql = "select mc.contractCode defaultContract, p.productCode, p.productName\nfrom MemberContract mc inner join PromotionProduct pp on mc.PromotionId=pp.PromotionId\ninner join PssProductCode p on pp.productCode=p.productCode\nand mc.contractCode not in (select contractCode from PromotionProductReceive)\nwhere memberCode=:p1 order by mc.contractCode, p.productCode";
		return this.queryListBySql(PssProductCode.class, sql, new Object[]{memberCode});
	}

	public boolean chkProductReceive(String contractCode, String productCode) {
		String sql = "select count(*) from PromotionProductReceive where contractCode=:p1 and productCode=:p2";
		return ((Integer)this.getBySql(Integer.class, sql, new Object[]{contractCode, productCode})).intValue() > 0;
	}

	public void addReceive(List<PromotionProductReceive> list) {
		Iterator i$ = list.iterator();

		while(i$.hasNext()) {
			PromotionProductReceive receive = (PromotionProductReceive)i$.next();
			this.add(receive);
		}

	}
}
